package File_11_4;

import java.io.*;

public class Copy {
    public static void main(String[] args) {
        copyFile();

    }

    private static void copyFile() {
        try {
            InputStream ip=new FileInputStream("D:\\Picture\\ps\\期末1.jpg");
            OutputStream op = new FileOutputStream("D:\\新11\\1.jpg");

            int n=-1;
            byte[]data=new byte[255];

            while ((n=ip.read(data))!=-1){
//                op.write(n);
                op.write(data,0,n);
                op.flush();
            }
            System.out.println("拷贝成功");
            ip.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e){
            e.printStackTrace();
            throw new RuntimeException(e);
        }


    }
}
